// import interface.
#include <Windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <setjmp.h>

void foo(char* mark) {
	char buf[16];
	if (!strcmp(mark, "main")) {
		strcpy(buf, "+++++");
	} else if (!strcmp(mark, "thread")) {
		strcpy(buf, "--");
	}

	printf("[%s] foo's buf: %p[%s]\n", mark, buf, buf);
}

DWORD WINAPI thread1(PVOID para) {
	printf("thread call foo: %p\n", foo);
	foo("thread");
	return 0;
}

int main(int argc, char* argv[]) {
	HANDLE hThread;
	{
		hThread = (HANDLE)_beginthreadex(NULL, 0, thread1,
				NULL, 0, NULL);
		assert(hThread);
	}

	printf("main call foo: %p\n", foo);
	foo("main");

	WaitForSingleObject(hThread, INFINITE);
	CloseHandle(hThread);
	return 0;
}
